package com.th;

import sun.awt.windows.ThemeReader;

/**
 * @version 1.0
 * @Author: 许啸林
 * @Date: 2021/8/30 14:25
 * 实现Runable 接口创建多线程
 */
public class Thread02 {
    public static void main(String[] args) {
        Dog dog = new Dog();
        Thread thread = new Thread(dog);
        thread.start();
    }
}

class Animals {
}

/**
 * 当需要继承　Thread 类的类已经继承父类时,
 * 可以实现Runable接口 + new Thread 类使用静态代理模式创建线程
 */
class Dog extends Animals implements Runnable {
    @Override
    public void run() {
        int offset = 0;
        while (offset < 10) {
            System.out.println("小狗吃饭 " + Thread.currentThread().getName());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}